const router = require('../../router');
const recordModel = require('../../../model/parperRecord')
const userdModel = require('../../../model/user')
const courseModel = require('../../../model/course')
const parperModel = require('../../../model/parper')

router.get('/learn2/zhenshu/:id', async (ctx) => {
    const record = await recordModel.findOne({
        where: {
            id: ctx.params.id
        },
        include: [
            {
                model: userdModel
            },
            {
                model: courseModel
            },
            {
                model: parperModel
            }
        ]
    })

    const viewData = {
        name: record.user.name,
        card: record.user.card,
        time: record.createdAt,
        year: record.createdAt.getFullYear(),
        number: `AHJXJY` + (10000000 + record.id),
        course: record.course.name
    }
    ctx.body = await ctx.render('learn/zhenshu', viewData)
})